package com.itheima.appserver.interceptor;

import com.itheima.model.domain.User;

public class UserHandler {
    private static ThreadLocal<User> tl = new ThreadLocal();

    //将用户存入Theadlocal
    public static void set(User user) {
        tl.set(user);
    }

    //从当前线程获取用户
    public static User get() {
        return tl.get();
    }

    //从当前线程获取用户id
    public static Long getId() {
        return tl.get().getId();
    }

    //获取用户手机
    public static String getPhone() {
        return tl.get().getMobile();
    }
    public static void remove(){
        tl.remove();
    }
}
